import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component:Home,
    redirect:'/admin/login'
  },
  {
    path: '/admin/login',
    name: 'admin_login',
    component: ()=>import('../views/admin/login/login')
  },
  {
    path: '/admin/home',
    name: 'admin_home',
    redirect:'/admin/welcome',
    component: () => import('../views/admin/home'),
    children: [
      // 欢迎页面
      {
        path: '/admin/welcome',
        name: 'admin_welcome',
        component: () => import('@/views/admin/welcome'),
      },
      // 用户管理
      {
        path: '/admin/users',
        name: 'admin_users',
        component: () => import('@/views/admin/user/user'),
      },
      // 权限管理
      {
        path: '/admin/rights',
        name: 'admin_rights',
        component: () => import('@/views/admin/rights/rights'),
      },
      // 角色管理
      {
        path: '/admin/roles',
        name: 'admin_roles',
        component: () => import('@/views/admin/rights/user'),
      },
      // 商品管理
      {
        path: '/admin/goods',
        name: 'admin_goods',
        component: () => import('@/views/admin/goods/goodsList'),
      },
      // 商品参数
      {
        path: '/admin/params',
        name: 'admin_params',
        component: () => import('@/views/admin/goods/params'),
      },
      // 商品分类
      {
        path: '/admin/categories',
        name: 'admin_categories',
        component: () => import('@/views/admin/goods/goodsNum'),
      },
      // 订单
      {
        path: '/admin/orders',
        name: 'admin_orders',
        component: () => import('@/views/admin/oder/oder'),
      },
      // 图表
      {
        path: '/admin/reports',
        name: 'admin_reports',
        component: () => import('@/views/admin/echarts/echarts'),
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
